package com.snow.campuslink.user.facade;

import com.snow.campuslink.user.converter.dto.UpdateBbsPostActionCountDto;
import com.snow.campuslink.user.converter.dto.UpdateLostFoundActionCountDto;
import com.snow.campuslink.user.converter.dto.UpdateSecondHandActionCountDto;
import com.snow.campuslink.user.entity.UserCollection;
import com.snow.campuslink.user.feign.BbsFeignService;
import com.snow.campuslink.user.feign.LostFoundFeignService;
import com.snow.campuslink.user.feign.SecondHandFeignService;
import com.snow.campuslink.user.service.IUserCollectionService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @author Gaosl
 * @className UserCollectionFacade
 * @date 2021/3/2 11:23
 */
@Component
public class UserCollectionFacade {

    @Resource
    IUserCollectionService userCollectionService;

    @Resource
    BbsFeignService bbsFeignService;
    @Resource
    LostFoundFeignService lostFoundFeignService;
    @Resource
    SecondHandFeignService secondHandFeignService;

    public void saveCollection(UserCollection userCollection) {
        userCollectionService.save(userCollection);
        switch (userCollection.getModule()) {
            case "BBS_POST":
                bbsFeignService.updateActionCount( new UpdateBbsPostActionCountDto(userCollection.getModuleId(),null,null,1,null));
                break;
            case "LOST_FOUND_POST":
                lostFoundFeignService.updateActionCount(new UpdateLostFoundActionCountDto(userCollection.getModuleId(),null,null,1,null));
                break;
            case "SECOND_HAND_GOODS":
                secondHandFeignService.updateActionCount(new UpdateSecondHandActionCountDto(userCollection.getModuleId(),null,null,1,null));
                break;
            default:
        }
    }
}
